package com.itany.springboot.controller;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/option")
public class OptionController implements ApplicationContextAware {

    private ApplicationContext ac;

    @RequestMapping("/add")
    public String add(){
        System.out.println("OptionController.add()");
        String str= (String) ac.getBean("s1");
        System.out.println("str = " + str);
        return "add";
    }

    @RequestMapping("/remove")
    public String remove(){
        System.out.println("OptionController.remove()");
        return "remove";
    }

    @RequestMapping("/modify")
    public String modify(){
        System.out.println("OptionController.modify()");
        return "add";
    }

    @RequestMapping("/find")
    public String find(){
        System.out.println("OptionController.find()");
        return "add";
    }


    @Override
    public void setApplicationContext(ApplicationContext ac) throws BeansException {
        this.ac=ac;
    }
}
